package org.example.librarysystemspringboot.service.impl;


import org.example.librarysystemspringboot.entity.model.BorrowRecords;
import org.example.librarysystemspringboot.repository.BorrowRecordsRepository;
import org.example.librarysystemspringboot.service.BorrowRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BorrowRecordsServiceImpl implements BorrowRecordsService {
    @Autowired
    private BorrowRecordsRepository borrowRecordsRepository;

    public List<BorrowRecords> getAllBorrowRecords() {
        return borrowRecordsRepository.findAll();
    }

    public BorrowRecords getBorrowRecordById(Integer id) {
        return borrowRecordsRepository.findById(id).orElse(null);
    }

    public BorrowRecords addBorrowRecord(BorrowRecords borrowRecords) {
        return borrowRecordsRepository.save(borrowRecords);
    }
}
